CC=clang
TARGET=mjs
SRC_PATH  := . 
SRC_PATH += js/mjs
SRC_PATH += js/frozen
SRC_PATH += js/common
SRC_PATH += js/mjs/src
SRC_PATH += js/mjs/src/ffi
LIBS :=
INCLUDE_PATH := ./ 
INCLUDE_PATH += js
LIBRARY_PATH :=

CFLAGS += -DMJS_EXPOSE_PRIVATE

SRCS += $(foreach dir, $(SRC_PATH), $(wildcard $(dir)/*.c))
# SRCS += $(wildcard $(SRC_PATH)/*.c)
OBJS := $(SRCS:.c=.o)
DEPS := $(SRCS:.c=.d)

CFLAGS  += $(foreach dir, $(INCLUDE_PATH), -I$(dir))
LDFLAGS += $(foreach lib, $(LIBRARY_PATH), -L$(lib))
LDFLAGS += $(foreach lib, $(LIBS), -l$(lib))

CFLAGS += -g3


all:$(TARGET)
$(TARGET):$(DEPS) $(OBJS) 
	@echo "LD $(TARGET)"
	@$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LDFLAGS)

%.d: %.c
	@echo "DEP $<"
	@$(CC) -MM $(CFLAGS) $< > $@	

.PHONY:clean  
clean:  
	rm -f $(OBJS) $(DEPS) $(TARGET)

%.o:%.c  
	@echo "CC $<"
	@$(CC) -Wall $(CFLAGS) -c $< -o $@